package com.echo.tagparse.face.stemmer;

public class StemmerDemo extends LovinsStemmer{

	public String stem(String str){
		if(str.length()<=2){
			return str;
		}
		String stemmed = super.stem(str);
		while(!stemmed.equals(str)){
			str = stemmed;
			stemmed = super.stem(stemmed);
		}
		return stemmed;
	}
	
	public static void main(String[] args){
		StemmerDemo sd = new StemmerDemo();
		
		try{
			int num;
			StringBuffer wordBuffer = new StringBuffer();
			while((num=System.in.read())!=-1){
				char c = (char)num;
				if(((num >= (int)'A') && (num <= (int)'Z')) ||
					    ((num >= (int)'a') && (num <= (int)'z'))){
					wordBuffer.append(c);
				}else{
					if(wordBuffer.length()>0){
						System.out.print(sd.stem(wordBuffer.toString().toLowerCase()));
						wordBuffer = new StringBuffer();
					}
					System.out.print(c);
				}
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
